<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>md0 一个丑陋的markdown解析工具</title>
    <script src="https://cdn.bootcss.com/Base64/1.0.2/base64.min.js"></script>
    <style id="style"></style>
    <script id="script"></script>
    <style>
    #content:empty {
        content: 'Loading...';
        font-size: 16px;
        color: #AAA;
        text-align: center;
        display: block;
    }
    </style>
</head>
<body>
<div id="content"></div>
<script>
function fromBase64(content) {
    return decodeURIComponent(escape(atob(content.replace(/\n/g, ''))))
}

var loadCount = 0

function loaded() {
    if (++loadCount < 3) {
        return
    }
    document.querySelector('#content').innerHTML = md0(document.querySelector('#content').innerHTML)
}

function mdCallback(response) {
    document.querySelector('#content').innerHTML = fromBase64(response.data.content)
    loaded()
}

function jsCallback(response) {
    document.querySelector('#script').innerHTML = fromBase64(response.data.content)
    loaded()
}

function cssCallback(response) {
    document.querySelector('#style').innerHTML = fromBase64(response.data.content)
    loaded()
}
</script>
<script src="https://api.github.com/repos/hyjiacan/md0/contents/src/md0.js?callback=jsCallback"
        type="text/javascript"
        charset="utf-8"></script>
<script src="https://api.github.com/repos/hyjiacan/md0/contents/src/md0.css?callback=cssCallback"
        type="text/javascript"
        charset="utf-8"></script>
<script src="https://api.github.com/repos/hyjiacan/md0/readme?callback=mdCallback"
        type="text/javascript"
        charset="utf-8"></script>
</body>
</html>
